% function see_impliedsd
% Use this code to see the implied VVCdec of a model as you switch
% parameters 

auth ='GIO'; 
spec ='DSSW'; 
subf = 'SIND'; 
modefile='mode e79 p84 pss'; 
modepath = 'STDSAMP'; 
outfold = 'STD'; 

oname = modefile; 

% ================================================================
cucd=cd; 
modelname=[auth spec]; 
opath=[cucd '\' auth '\' spec '\' subf];
modname= ['mod',modelname] ; 

% LOADING THE MODE FILE 
% ---------------------
if isempty( modepath ); 
    mode_path = opath ;
else 
    mode_path = [opath,'\',modepath]; 
    cd(mode_path); 
    disp( [ 'Loading mode file from : ',mode_path ] );
    cd( cucd ); 
end
disp( [ 'Loading mode file from : ',opath ] );     

outpath =newdir( mode_path, outfold );     


cd( mode_path ); 
[cofname,fullp]=textread( [modefile,'.txt'],'%q%f');
[cofname]=textread([modefile,'.txt'],'%q%*[^\n]');
cd( cucd ); 
clear temp*; 

%clear mode_path ; 

disp('--------------'); 
disp('Mode settings'); 
disp('--------------'); 
numpar=size(fullp,1); 
cd(cucd); 
disp(' '); 
disp('_____________________________________'); 
disp('    Mode / Parameters       '); 
temp=num2cprec(fullp,3); 
temp=[cofname temp]; 
printcell( temp ); 
quer('c'); 
clear temp; 

% ============
% Output cell 
% ============
topcell = emptycell( numpar + 4  , 4); 
topcell(1,1:4) = { 'Model:', modelname , 'Subfolder', subf } ; 
topcell(2,1:4) = { 'Mode File', modefile,'Folder',outfold};
topcell(3,1) = { outpath }; 
topcell(4,1)   = {'Parameters'}; 
topcell(5:end,1) = cofname; 
topcell(5:end,2) = num2cprec( fullp ); 


[G1,C,HH,eu,SDX,zmat,ny,nx,NETA,gev]=play_eugen(modname,fullp);

[ACzero,ACone,vcfull,sdevf]=vardecom_simp(G1,HH,SDX,zmat); 

sdevf=sdevf(:); 

nz = size( zmat , 1 ); 
tcell = emptycell(nz+3,1); 
tcell(1) = {'Std MODEL'};
tcell(2) = {'File:'}; 
tcell(3)=  {oname }; 
tcell(4:end) = num2cprec( sdevf , 3 ); 

topcell = merge_cells( topcell, tcell ); 
savecell( topcell, cucd, outpath, oname ); 
